#ifndef __THREAD_POOL__
#define __THREAD_POOL__
#include "head.h"
#include "workerData.h"
#include "taskQueue.h"
#include "kickOut.h"
//
#include "../../command/metaFile.h"
//#include "transfile.h"
#include "../../command/command.h"
/* #include "../../command/metaFile.h" */
#define SECRET "helloworld"
typedef struct threadPool_s {
    //工人信息
    workerData_t workerArr; 
    //任务队列
    taskQueue_t taskQueue;
    //锁
    pthread_mutex_t mutex;
    //条件变量
    pthread_cond_t cond;
} threadPool_t;

enum{
     CD=1,
     LS,
     PWD,
     PUTS,
     GETS,
     MKDIR,
     RMDIR,
     REMOVE,
};

typedef struct train_s{
    int flag;
    int length;
    char data[4096];                                          
}train_t;


int threadPoolInit(threadPool_t *pthreadPool, int workerNum);// 线程池初始化
int tcpInit(char *ip, char *port);// 初始化tcp连接
int epollAdd(int epfd, int sockfd);// 加入监听
int epollDel(int epfd, int sockfd);// 取消监听
int makeWorker(threadPool_t *pthreadPool);// 制造工人
                                          
int isInTable(MYSQL *mysql,const char *userName);// 查看用户是否存在
int checkPassword(MYSQL *mysql,const char *userName,const char *password);// 查看用户密码是否正确
int addUser(MYSQL *mysql,const char *userName,const char *password,const char *salt);// 添加一个用户条目
int checkSalt(MYSQL *mysql,const char *userName,char *salt);// 根据用户名比对盐值
int Register(MYSQL *mysql,const char *userName, const char *userPwd);// 注册
int logIn(MYSQL *mysql,const char *userName, const char *userPwd);// 登录
                                                                   
int sendCmd_p(int sockfd,char* buf,int flag,int *pathid);
int recvCmd_p(int sockfd, char *buf, int *flag,int *pathid);
int sendFile(int sockfd,char* buf,char *fileRealName,int flag);// 发送文件
int recvFile(int sockfd,char* buf,int *flag);// 接收文件
//  使用小火车传输，小火车的flag默认为-1，小火车的data传输token
int sendToken(int sockfd, char *token);
//  接收token
int recvToken(int sockfd, char *token);


int getToken(char *userName, char *token, char *secretKey);
int userTokenDecode(const char *token,const char *secretKey,char *userName);
#endif
